package com.bmft.project02.node;

/**
 * @author Jarvan
 * @version 1.0
 * @create 2020/9/24 12:43
 */
public class Node<E> {

    /**
     * value of Node.
     */
    private E item;
    /**
     * Next Node
     */
    private Node<E> next;
    /**
     * Previous Node
     */
    private Node<E> previous;

    /**
     * No constructor function.
     */
    public Node() {
    }

    /**
     * Init value of item.
     *
     * @param item value of Item.
     */
    public Node(E item) {
        this.item = item;
    }

    /**
     * Init the Node.
     * @param item
     * @param next
     * @param previous
     */
    public Node(E item, Node<E> next, Node<E> previous) {
        this.item = item;
        this.next = next;
        this.previous = previous;
    }

    @Override
    public String toString() {
        return "item ="+item;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Node<?> node = (Node<?>) o;

        return item.equals(node.item);
    }

    @Override
    public int hashCode() {
        return item.hashCode();
    }

    public E getItem() {
        return item;
    }

    public void setItem(E item) {
        this.item = item;
    }

    public Node<E> getNext() {
        return next;
    }

    public void setNext(Node<E> next) {
        this.next = next;
    }

    public Node<E> getPrevious() {
        return previous;
    }

    public void setPrevious(Node<E> previous) {
        this.previous = previous;
    }
}
